import {

} from 'services';

/**
 * 检索-列表
 */
const defaultState = {

  /**
   * 查询表单初始数据
   */
  queryFormState: {
    status:'',
    name: '',
  },

  /**
   * 新增表单对应的状态
   */
  addFormModalState: {
    visible: false,
  },

  /**
   * 编辑表单对应的状态
   */
  editFormModalState: {
    visible: false,
  },

  /**
   * 编辑白名单表单初始值
   */
  editFormState: {
    address: '',
    remarks: '',
    name: '',
    KeyID: '',
    KeySecret: '',
    gmtCreate: '',
  },

}

export default {

  namespace: 'pages_home_system_white_list',

  state: defaultState,

  effects: {

  },

  reducers: {
    /**
     * 更新检索表单状态(状态要整体传入)
     */
    queryFormStateUpdate(state, { payload }){
      const { queryFormState } = state;
      return { ...state, queryFormState: { ...queryFormState, ...payload } };
    },

    /**
     * 重置检索表单状态(状态要整体传入)
     */
    queryFormStateReset(state) {
      const { formCollapsed } = state.queryFormState;
      return { ...state, queryFormState: { ...defaultState.queryFormState, formCollapsed } }
    },

    /**
     * 更新编辑表单弹窗的状态
     */
    editFormModalStateUpdate (state, { payload }) {
      const { editFormModalState } = state;
      return { ...state, editFormModalState: { ...editFormModalState, ...payload } }
    },

    /**
     * 更新编辑表单初始值
     */
    editFormStateUpdate (state, { payload }) {
      const { editFormState } = state;
      return { ...state, editFormState: { ...editFormState, ...payload } }
    },

    /**
     * 更新新增表单状态
     */  
    addFormModalStateUpdate (state, { payload }) {
      const { addFormModalState } = state;
      return { ...state, addFormModalState: { ...addFormModalState, ...payload } }
    },

    /**
     * 更新liststate状态
     */
    liststateUpdate(state, { payload }) {
      const { liststate } = state;
      return { ...state, liststate: { ...liststate, ...payload } };
    },

    /**
     * 重置页面状态
     */
    allStateReset(state) {
      return defaultState;
    },
    
  },

}